{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Naive Bayes Classification"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>pregnant</th>\n",
       "      <th>glucose</th>\n",
       "      <th>bp</th>\n",
       "      <th>skin</th>\n",
       "      <th>insulin</th>\n",
       "      <th>bmi</th>\n",
       "      <th>pedigree</th>\n",
       "      <th>age</th>\n",
       "      <th>label</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>6</td>\n",
       "      <td>148</td>\n",
       "      <td>72</td>\n",
       "      <td>35</td>\n",
       "      <td>0</td>\n",
       "      <td>33.6</td>\n",
       "      <td>0.627</td>\n",
       "      <td>50</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>85</td>\n",
       "      <td>66</td>\n",
       "      <td>29</td>\n",
       "      <td>0</td>\n",
       "      <td>26.6</td>\n",
       "      <td>0.351</td>\n",
       "      <td>31</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>8</td>\n",
       "      <td>183</td>\n",
       "      <td>64</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>23.3</td>\n",
       "      <td>0.672</td>\n",
       "      <td>32</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>89</td>\n",
       "      <td>66</td>\n",
       "      <td>23</td>\n",
       "      <td>94</td>\n",
       "      <td>28.1</td>\n",
       "      <td>0.167</td>\n",
       "      <td>21</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>137</td>\n",
       "      <td>40</td>\n",
       "      <td>35</td>\n",
       "      <td>168</td>\n",
       "      <td>43.1</td>\n",
       "      <td>2.288</td>\n",
       "      <td>33</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   pregnant  glucose  bp  skin  insulin   bmi  pedigree  age  label\n",
       "0         6      148  72    35        0  33.6     0.627   50      1\n",
       "1         1       85  66    29        0  26.6     0.351   31      0\n",
       "2         8      183  64     0        0  23.3     0.672   32      1\n",
       "3         1       89  66    23       94  28.1     0.167   21      0\n",
       "4         0      137  40    35      168  43.1     2.288   33      1"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Import libraries\n",
    "import pandas as pd\n",
    " \n",
    "# read the dataset\n",
    "diabetes = pd.read_csv(\"diabetes.csv\")\n",
    " \n",
    "    \n",
    "# Show top 5-records\n",
    "diabetes.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "# split dataset in two parts: feature set and target label \n",
    "feature_set = ['pregnant', 'insulin', 'bmi', 'age','glucose','bp','pedigree']\n",
    "features = diabetes[feature_set] \n",
    "target = diabetes.label\n",
    " \n",
    "# partition data into training and testing set \n",
    "from sklearn.model_selection import train_test_split\n",
    "feature_train,feature_test, target_train, target_test = \\\n",
    "train_test_split(features, target, test_size=0.3, random_state=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Import Gaussian Naive Bayes model\n",
    "from sklearn.naive_bayes import GaussianNB\n",
    "\n",
    "# Create a Gaussian Classifier\n",
    "model = GaussianNB()\n",
    " \n",
    "# Train the model using the training sets\n",
    "model.fit(feature_train,target_train)\n",
    " \n",
    "# Forecast the target variable for given test dataset\n",
    "predictions = model.predict(feature_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Accuracy: 0.7748917748917749\n",
      "Precision: 0.7391304347826086\n",
      "Recall: 0.6\n",
      "F1-Score: 0.6623376623376623\n"
     ]
    }
   ],
   "source": [
    "# Import metrics module for performance evaluation\n",
    "from sklearn.metrics import accuracy_score\n",
    "from sklearn.metrics import precision_score\n",
    "from sklearn.metrics import recall_score\n",
    "from sklearn.metrics import f1_score\n",
    " \n",
    "# Calculate model accuracy\n",
    "print(\"Accuracy:\",accuracy_score(target_test, predictions))\n",
    "# Calculate model precision\n",
    "print(\"Precision:\",precision_score(target_test, predictions))\n",
    "# Calculate model recall\n",
    "print(\"Recall:\",recall_score(target_test, predictions))\n",
    "# Calculate model f1 score\n",
    "print(\"F1-Score:\",f1_score(target_test, predictions))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Decision Tree Classification"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Accuracy: 0.683982683982684\n",
      "Precision: 0.581081081081081\n",
      "Recall: 0.5058823529411764\n",
      "F1-Score: 0.540880503144654\n"
     ]
    }
   ],
   "source": [
    "# Import Decision Tree model \n",
    "from sklearn.tree import DecisionTreeClassifier\n",
    "\n",
    "# Import metrics module for performance evaluation\n",
    "from sklearn.metrics import accuracy_score\n",
    "from sklearn.metrics import precision_score\n",
    "from sklearn.metrics import recall_score\n",
    "from sklearn.metrics import f1_score\n",
    " \n",
    "# Create a Decision Tree classifier object\n",
    "clf = DecisionTreeClassifier()\n",
    " \n",
    "# Train the model using training dataset\n",
    "clf = clf.fit(feature_train,target_train)\n",
    " \n",
    "# Predict the response for test dataset\n",
    "predictions = clf.predict(feature_test)\n",
    " \n",
    "# Calculate model accuracy\n",
    "print(\"Accuracy:\",accuracy_score(target_test, predictions))\n",
    "# Calculate model precision\n",
    "print(\"Precision:\",precision_score(target_test, predictions))\n",
    "# Calculate model recall\n",
    "print(\"Recall:\",recall_score(target_test, predictions))\n",
    "# Calculate model f1 score\n",
    "print(\"F1-Score:\",f1_score(target_test, predictions))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## K-Nearest Neighbors Classification"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Accuracy: 0.7532467532467533\n",
      "Precision: 0.7058823529411765\n",
      "Recall: 0.5647058823529412\n",
      "F1-Score: 0.6274509803921569\n"
     ]
    }
   ],
   "source": [
    "# Import KNN model\n",
    "from sklearn.neighbors import KNeighborsClassifier\n",
    " \n",
    "# Create a KNN classifier object\n",
    "model = KNeighborsClassifier(n_neighbors=3)\n",
    " \n",
    "# Train the model using the training dataset\n",
    "model.fit(feature_train,target_train)\n",
    " \n",
    "# Predict the target variable for test dataset\n",
    "predictions = model.predict(feature_test)\n",
    " \n",
    "# Import metrics module for performance evaluation\n",
    "from sklearn.metrics import accuracy_score\n",
    "from sklearn.metrics import precision_score\n",
    "from sklearn.metrics import recall_score\n",
    "from sklearn.metrics import f1_score\n",
    " \n",
    "# Calculate model accuracy\n",
    "print(\"Accuracy:\",accuracy_score(target_test, predictions))\n",
    "# Calculate model precision\n",
    "print(\"Precision:\",precision_score(target_test, predictions))\n",
    "# Calculate model recall\n",
    "print(\"Recall:\",recall_score(target_test, predictions))\n",
    "# Calculate model f1 score\n",
    "print(\"F1-Score:\",f1_score(target_test, predictions))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## SVM Classification"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Accuracy: 0.7835497835497836\n",
      "Precision: 0.7868852459016393\n",
      "Recall: 0.5647058823529412\n",
      "F1-Score: 0.6575342465753424\n"
     ]
    }
   ],
   "source": [
    "# Import SVM model\n",
    "from sklearn import svm\n",
    " \n",
    "# Create a SVM classifier object\n",
    "clf = svm.SVC(kernel='linear') \n",
    " \n",
    "# Train the model using the training sets\n",
    "clf.fit(feature_train,target_train)\n",
    " \n",
    "# Predict the target variable for test dataset\n",
    "predictions = clf.predict(feature_test)\n",
    " \n",
    "# Import metrics module for performance evaluation\n",
    "from sklearn.metrics import accuracy_score\n",
    "from sklearn.metrics import precision_score\n",
    "from sklearn.metrics import recall_score\n",
    "from sklearn.metrics import f1_score\n",
    " \n",
    "# Calculate model accuracy\n",
    "print(\"Accuracy:\",accuracy_score(target_test, predictions))\n",
    "# Calculate model precision\n",
    "print(\"Precision:\",precision_score(target_test, predictions))\n",
    "# Calculate model recall\n",
    "print(\"Recall:\",recall_score(target_test, predictions))\n",
    "# Calculate model f1 score\n",
    "print(\"F1-Score:\",f1_score(target_test, predictions))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Confusion Matrix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<sklearn.metrics._plot.confusion_matrix.ConfusionMatrixDisplay at 0x7fcc4d849c40>"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAATgAAAEGCAYAAADxD4m3AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cG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lmOcGZWWY5wZlZZjnBmVlmOcGZWWb9f5FdbsMgbwNAAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Import libraries\n",
    "import pandas as pd\n",
    " \n",
    "# read the dataset\n",
    "diabetes = pd.read_csv(\"diabetes.csv\")\n",
    "\n",
    "# split dataset in two parts: feature set and target label \n",
    "feature_set = ['pregnant', 'insulin', 'bmi', 'age','glucose','bp','pedigree']\n",
    "features = diabetes[feature_set] \n",
    "target = diabetes.label\n",
    " \n",
    "# partition data into training and testing set \n",
    "from sklearn.model_selection import train_test_split\n",
    "feature_train, feature_test, target_train, target_test = train_test_split(features, target, test_size=0.3, random_state=1)\n",
    "\n",
    "# import logistic regression scikit-learn model\n",
    "from sklearn.linear_model import LogisticRegression\n",
    "from sklearn.metrics import accuracy_score # for performance evaluation\n",
    " \n",
    "# instantiate the model\n",
    "logreg = LogisticRegression(solver='lbfgs')\n",
    " \n",
    "# fit the model with data\n",
    "logreg.fit(feature_train,target_train)\n",
    " \n",
    "# Forecast the target variable for given test dataset\n",
    "predictions = logreg.predict(feature_test)\n",
    "\n",
    "# Get prediction probability \n",
    "predictions_prob = logreg.predict_proba(feature_test)[::,1]\n",
    "\n",
    "\n",
    "# Import the confusion matrix\n",
    "from sklearn.metrics import plot_confusion_matrix\n",
    "\n",
    "# Plot Confusion matrix\n",
    "plot_confusion_matrix(logreg , feature_test, target_test, values_format='d')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Confusion Report"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              precision    recall  f1-score   support\n",
      "\n",
      "      Yes(1)       0.79      0.90      0.84       146\n",
      "       No(0)       0.78      0.58      0.66        85\n",
      "\n",
      "    accuracy                           0.78       231\n",
      "   macro avg       0.78      0.74      0.75       231\n",
      "weighted avg       0.78      0.78      0.78       231\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# import classification report\n",
    "from sklearn.metrics import classification_report\n",
    "\n",
    "# Create classification report\n",
    "print(classification_report(target_test, predictions, target_names=['Yes(1)','No(0)']))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## ROC Curve and AUC"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<sklearn.metrics._plot.roc_curve.RocCurveDisplay at 0x7fcc4fed21f0>"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEGCAYAAABo25JHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nO3df3wV1bnv8c9jgEIRERHO5YcIIlpBfqhRUECQ9lBQW0StCFarB+vhFH9Ur73g0SOoPUWvvCrlaKWIVG0Vy1FRpIrouSioWH5IRECBqIhRrBEUQYoSee4fM4k7YSeZkMze2Znv+/XKiz0za2aeSXQ/s9asWcvcHRERSa6Dsh2AiIhklxKBiEjCKRGIiCScEoGISMIpEYiIJFyjbAdQU4cffrh37tw522GIiOSUVatWferubdJty7lE0LlzZ1auXJntMEREcoqZvV/ZNjUNiYgknBKBiEjCKRGIiCScEoGISMIpEYiIJFxsicDMZpvZJ2a2tpLtZmbTzazQzNaY2YlxxSIiIpWLs0bwADCsiu3DgW7hzxXAvTHGIiIilYjtPQJ3X2JmnasoMgJ4yINxsF8zs0PNrJ27b40rJhGRXPHI37bwVMGH5dZ1b38Ik37Uo87Plc1nBB2AD1KWi8J1+zGzK8xspZmtLC4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K9e3d69OjBmDFjACguLmbYsGG1ii2VEoFIPZCfn8/06dMr3V4xEVRXvtTixYtZs2YNgwcP5te//nWt43T3cl+uB2rcuHFccskltT4OwG9/+1t+/vOfly3v27ePefPmccQRR7BkyZJIx3B3Ro4cyeDBg3nnnXdYv349v/nNb/j73/9eq9juv/9+WrVqRWFhIddeey0TJkzYr0xJSQnXXHNN2d+qV69e3H333QBs2rSJKVOm8Morr7Bu3TqmTZsGQJs2bWjXrh2vvPJKreIrpV5D0mDc8vQ61n/0RZ0es3v7Q5j0ox413q+goIBx48axe/duunbtyuzZs2nVqhUrVqxg7NixNG/enAEDBvDss8+ydu1aXnzxRaZOncqCBQt46aWXuOaaa4CgvXfJkiVMnDiRt956iz59+vCzn/2ME044oaz8rl27uOqqq1i5ciVmxqRJkzjvvPPKxXPqqaeWJY7i4mLGjRvHli1bAJg2bRr9+/enuLiYMWPGsG3bNk4++WQWLlzIqlWr2LVrF8OHD+eMM85g2bJlPPnkk8ydO5e5c+fy1VdfMXLkSG655Ra+/PJLLrjgAoqKivjmm2/4j//4D0aNGsXEiROZP38+jRo1YujQoUydOpXJkydz8MEHc/3111f6uxo8eDB9+/Zl8eLFfP7559x///0MHDhwv9/1448/Xi7JLV68mOOPP55Ro0YxZ84cBg8eXO3fa/HixTRu3Jhx48aVrevTp0+N/+4VPfXUU0yePBmA888/nyuvvBJ3L9eO7+64O19++SWtW7fmiy++4OijjwbgvvvuY/z48bRq1QqAtm3blu13zjnn8PDDD9O/f/9ax6kagUgMLrnkEu644w7WrFlDz549ueWWWwC47LLLmDFjBsuWLSMvLy/tvlOnTuWee+6hoKCApUuX0qxZM26//XYGDhxIQUEB1157bbnyt912Gy1btuTNN99kzZo1DBkyZL9jLly4kHPOOQcImk2uvfZaVqxYweOPP87ll18OwC233MKQIUN4/fXXGTlyZFmiANiwYQOXXHIJq1evZsOGDWzatInly5dTUFDAqlWrWLJkCQsXLqR9+/a88cYbrF27lmHDhrF9+3bmzZvHunXrWLNmDTfddFPk3xUEd8vLly9n2rRp5daXeu+992jVqhXf+c53ytbNmTOH0aNHM3LkSBYsWMDevXsr/TuVWrt2LSeddFK15QAGDhxInz599vt54YUX9iv74YcfcsQRRwDQqFEjWrZsybZt28qVady4Mffeey89e/akffv2rF+/nrFjxwKwceNGNm7cSP/+/enXrx8LFy4s2y8/P5+lS5dGirk6qhFIg3Egd+5x2LFjB59//jmDBg0C4Gc/+xk/+clP+Pzzz9m5cyennXYaAGPGjGHBggX77d+/f3+uu+46LrroIs4991w6duxY5fleeOEFHn300bLl0rtHgDPOOIO///3vtG3btuyu+YUXXmD9+vVlZb744gt27tzJyy+/zLx58wAYNmxYueMceeSR9OvXD4BFixaxaNEiTjjhBAB27drFpk2bGDhwINdffz0TJkzg7LPPZuDAgZSUlNC0aVMuv/xyzjrrrP3a8iv7XZU699xzATjppJPStq9v3bqVNm3alC1//fXXPPPMM9x11120aNGCvn37smjRIs4666xKe9PUtJdNTb583b3a8+3du5d7772X1atXc9RRR3HVVVcxZcoUbrrpJkpKSti0aRMvvvgiRUVFDBw4kLVr13LooYfStm1bPvrooxrFXplYawRmNszMNphZoZlNTLPdzGx6uH2NmZ0YZzwi2ZTuSyGdiRMnMmvWLP7xj3/Qr18/3n777WqPW9mX2eLFi3n//ffp0aMHN998MxC0oS9btoyCggIKCgr48MMPadGiRZXxNW/evNz5brjhhrL9CwsLGTt2LMcccwyrVq2iZ8+e3HDDDdx66600atSI5cuXc9555/Hkk0/W+AFn6Z1+Xl4eJSUl+21v1qxZuT7zCxcuZMeOHfTs2ZPOnTvz8ssvM2fOHABat27NZ599Vm7/nTt3cuihh9KjRw9WrVoVKaaa1Ag6duzIBx98AAS1mx07dnDYYYeVK1NQUABA165dMTMuuOACXn311bL9R4wYQePGjenSpQvHHnssmzZtAoJ3aJo1axYp5urElgjMLA+4BxgOdAdGm1n3CsWGA93CnyuAe+OKRyRTWrZsSatWrcruHP/0pz8xaNAgWrVqRYsWLXjttdcAyt3Fp3rnnXfo2bMnEyZMID8/n7fffpsWLVqwc+fOtOWHDh1a9nAR2O/LrlmzZkybNo2HHnqI7du371e+9ItowIABzJ07Fwju+isep9QPf/hDZs+eza5du4Cg+eOTTz7ho48+4rvf/S4//elPuf7663n99dfZtWsXO3bs4Mwzz2TatGll56rudxXVMcccU66mMGfOHGbNmsXmzZvZvHkz7733HosWLWL37t2cfvrpzJ8/v+z3+MQTT9C7d2/y8vIYMmQIX331Fffdd1/ZsVasWMFLL7203zmXLl1algRTf37wgx/sV/bHP/4xDz74IACPPfYYQ4YM2S9pd+jQgfXr11NcXAzA888/z3HHHQcEzwEWL14MwKeffsrGjRs56qijgKDZ6Pjjj4/8u6pKnE1DpwCF7v4ugJk9CowA1qeUGQE85MGtyGtmdqiZtXP3rTHGJVKndu/eXa755rrrruPBBx8sewB61FFH8cc//hEIepH8/Oc/p3nz5gwePJiWLVvud7xp06axePFi8vLy6N69O8OHD+eggw6iUaNG9O7dm0svvbSsWQbgpptuYvz48Rx//PHk5eUxadKksiaVUu3atWP06NHcc889TJ8+nfHjx9OrVy9KSko4/fTTmTFjBpMmTWL06NH85S9/YdCgQbRr144WLVqUfeGXGjp0KG+99RannnoqEHSf/fOf/0xhYSG/+tWvOOigg8ravXfu3MmIESPYs2cP7s5dd9213/VW9ruKonnz5nTt2pXCwkLat2/Pc889xx/+8Idy2wcMGMDTTz/NqFGjuPLKKxkwYABmRtu2bZk1axYQNNfMmzePX/7yl9x+++00bdqUzp07l/XSOVBjx47l4osv5uijj+awww4rl/z79OlDQUEB7du3Z9KkSZx++uk0btyYI488kgceeAAIku6iRYvo3r07eXl53HnnnbRu3RoIantnnXVWreIrU/rEuq5/gPOBWSnLFwN3VyizABiQsvw/QH6aY10BrARWdurUyQ/E5PlrffL8tQe0r9Rf69evz3YINbJz586yz1OmTPGrr746i9GUt2fPHt+7d6+7u7/66qveu3fvLEcUzRNPPOE33nhjtsPIuIEDB/r27dvTbkv3/wWw0iv5vo6zRpCu0bJiI2SUMrj7TGAmQH5+fr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X/3wA/DT8fSjAGUfNs/731k92fBjfEhDQY/3D3PqULZtYY+I2ZnU4wdEIH4J+Aj1P2WQHMDss+6e4FZjYI6A68Eg6t0YTgTjqdO83sJqCYYITW7wPzPBjADTN7AhgILASmmtkdBM1JS2twXc8C083sO8AwYIm7/yNsjupl386i1hLoBrxXYf9mZlYAdAZWAc+nlH/QzLoRjETZuJLzDwV+bGbXh8tNgU7k9nhEUktKBJIrLiKYfeokd99rZpsJvsTKuPuSMFGcBfzJzO4EPgOed/fREc7xK3d/rHTBzH6QrpC7bzSzkwjGe5liZovc/dYoF+Hue8zsRYKhk0cBc0pPB1zl7s9Vc4h/uHsfM2sJLADGA9MJxttZ7O4jwwfrL1ayvwHnufuGKPFKMugZgeSKlsAnYRI4AziyYgEzOzIscx9wP8F0f68B/c2stM3/u2Z2TMRzLgHOCfdpTtCss9TM2gO73f3PwNTwPBXtDWsm6TxKMFDYQILB1Aj//bfSfczsmPCcabn7DuBq4Ppwn5bAh+HmS1OK7iRoIiv1HHCVhdUjMzuhsnNIcigRSK54GMg3s5UEtYO305QZDBSY2WqCdvzfuXsxwRfjHDNbQ5AYvhflhO7+OsGzg+UEzwxmuftqoCewPGyiuRH4dZrdZwJrSh8WV7CIYF7aFzyYfhGCeSLWA69bMGn5H6imxh7G8gbB0Mz/l6B28grB84NSi4HupQ+LCWoOjcPY1obLknDqPioiknCqEYiIJJwSgYhIwikRiIgknBKBiEjCKRGIiCScEoGISMIpEYiIJNz/B0D17r4Q9voQAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# import plot_roc_curve\n",
    "from sklearn.metrics import plot_roc_curve\n",
    "\n",
    "plot_roc_curve(logreg, feature_test, target_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Area Under Curve: 0.8628525382755843\n"
     ]
    }
   ],
   "source": [
    "# import roc auc score\n",
    "from sklearn.metrics import roc_auc_score\n",
    "\n",
    "# Compute the area under ROC curve\n",
    "auc = roc_auc_score(target_test, predictions_prob)\n",
    "\n",
    "# Print auc value\n",
    "print(\"Area Under Curve:\",auc)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
